From 1ef9e0e610d5ee586173991390e4a19d281379ea Mon Sep 17 00:00:00 2001 From: Paul Donald Date: Thu, 30 Oct 2025 01:53:44 +0100 Subject: [PATCH] router: utilize interface ra_mtu for RA MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit MTU is now set at configure time. Change ra_mtu to uint32 since it never stores a negative value. Signed-off-by: Paul Donald Link: https://github.com/openwrt/odhcpd/pull/296 Signed-off-by: Álvaro Fernández Rojas --- src/odhcpd.h | 2 +- src/router.c | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/odhcpd.h b/src/odhcpd.h index e503029..3659f08 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -406,7 +406,7 @@ struct interface { uint32_t ra_reachabletime; uint32_t ra_retranstime; uint32_t ra_hoplimit; - int ra_mtu; + uint32_t ra_mtu; uint32_t max_preferred_lifetime; uint32_t max_valid_lifetime; diff --git a/src/router.c b/src/router.c index f841b2f..82d3187 100644 --- a/src/router.c +++ b/src/router.c @@ -569,7 +569,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr * for shortest lived prefix */ uint32_t lowest_found_lifetime = UINT32_MAX, highest_found_lifetime = 0, maxival, ra_lifetime; - int msecs, mtu = iface->ra_mtu, hlim = iface->ra_hoplimit; + int msecs, hlim = iface->ra_hoplimit; bool default_route = false; bool valid_prefix = false; char buf[INET6_ADDRSTRLEN]; @@ -602,13 +602,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr adv.mtu.nd_opt_mtu_type = ND_OPT_MTU; adv.mtu.nd_opt_mtu_len = 1; - if (mtu == 0) - mtu = odhcpd_get_interface_config(iface->ifname, "mtu"); - - if (mtu < 1280) - mtu = 1280; - - adv.mtu.nd_opt_mtu_mtu = htonl(mtu); + adv.mtu.nd_opt_mtu_mtu = htonl(iface->ra_mtu); iov[IOV_RA_ADV].iov_base = (char *)&adv; iov[IOV_RA_ADV].iov_len = sizeof(adv); -- 2.30.2